package br.com.jvet.persistencia;

import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;
import javax.persistence.Query;

import br.com.jvet.entidade.Animal;
import br.com.jvet.entidade.Cliente;

@Stateless
public class ClienteDAO extends AbstractDAO<Cliente, Integer> {

	private static String SELECT_PARAMETRO = "SELECT c from "
			+ Cliente.class.getSimpleName()
			+ " c where c.dadosCadastro.dataCadastro between :dataInicial and :dataFinal";
	

	public ClienteDAO() {
		super(Cliente.class);

	}

	public List<Cliente> buscaPorListaParametro(Map<String, Object> parameters) {
		return super.buscarListaParametro(SELECT_PARAMETRO, parameters);
	}

	@SuppressWarnings("unchecked")
	public List<Animal> consultarAnimais(Cliente cliente) {
		Query c = super.getEntityManager().createQuery(
				"SELECT a FROM " + Animal.class.getSimpleName()
						+ " a  where a.cliente =:cliente");

		c.setParameter("cliente", cliente);

		return (List<Animal>) c.getResultList();
	}

}
